<template>
	<view class="content_box">
		<view class="vide">

			<view class="title mt36 ww100">
				166008
			</view>
			<view class="ww100 text-center mt60">
				<text>请根据视频提示读出相关数字</text>
			</view>

			<view class="ww100 mt80">
				
				<view v-if="src" class="w570 h420 r20 flex justify-center " style="margin: auto;">
					<video style="margin: auto; border-radius: 20;" :src="src"></video>
				</view>
				
				<view v-else class="w570 h600 r20 flex justify-center" style="background-color: #F5F5F5; margin: 0 auto;"
					@click="videoInput">
					<view class="cuIcon-add" style="margin: auto; font-size: 90rpx; color: #B3B3B3;"></view>
				</view>

				<view class=" text-center r40" style=" margin: 100rpx auto 0;">
					<text style="color: #333333;">录像</text>

					<view class="w120 h120 r60" style="background-color: #D6D6D6; margin: 10rpx auto; ">
					</view>
				</view>
			</view>
		</view>
		<view class="foot_box"></view>
		<!-- 加载提示 -->
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<!-- 信息提示-->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: '',
			};
		},
		onShow() {},
		onLoad(e) {},
		methods: {
			clkOn() {
				this.z.load(this);
				setTimeout(() => {
					this.z.load(this, 0);
				}, 3000);
			},

			videoInput() {
				var self = this;
				uni.chooseVideo({
					count: 1,
					sourceType: ['camera', 'album'],
					success: function(res) {
						console.log('res==>', res);
						self.src = res.tempFilePath;
						console.log('self.src==>', self.src);
					}
				});
			},

			saveVideo() {
				let _this = this;
				uni.chooseVideo({
					count: 1,
					sourceType: ['camera'],
					success: res => {
						console.log(res.tempFilePath)
						
						_this.videoPath = res.tempFilePath;
						console.log('_this.videoPath==>',_this.videoPath );
						_this.getTempFilePath(res.tempFilePath, 'videoTempPath');
					},
					fail: (err) => {
						uni.getSetting({
							success: (res) => {
								let authStatus = res.authSetting['scope.camera'];
								if (!authStatus) {
									uni.showModal({
										title: '授权失败',
										content: 'Hello uni-app需要从您的相机获取视频，请在设置界面打开相关权限',
										success: (res) => {
											if (res.confirm) {
												uni.openSetting()
											}
										}
									})
								}
							}
						})
					}
				});
			},

		}
	};
</script>

<style lang="scss" scoped>
	.content_box {
		padding: 204rpx 31rpx;

		.vide {

			.title {
				font-size: 36rpx;
				font-family: PingFang SC;
				color: #000000;
				overflow: hidden;
				text-align: center;
			}
		}
	}
</style>
